<script src="<?php echo $this->config->item('base_url'); ?>js/echarts/dist/echarts.js"></script>
<script src="<?php echo $this->config->item('base_url'); ?>js/echarts/theme/macarons.js"></script>
<div id="region-bar-chart" style="height:550px;width: 1100px;overflow: hidden;margin:auto;margin-top: 5px;">loading......</div>
<script>
    $(function () {
        var region = [];
        region.init = function () {
            this.barchart = echarts.init(document.getElementById('region-bar-chart'), 'macarons');
            this.getRegionBarChart();
        }
        region.getRegionBarChart = function () {
            $.ajax({
                url: '<?php echo $this->config->item('base_url'); ?>visitor/getbarchart',
                method: 'post',
                success: function (re) {
                    var obj = $.parseJSON(re);
                    category = obj['category'];
                    data = obj['data'];
                    baroption = {
                        color: ['#3398DB'],
                        tooltip: {
                            trigger: 'axis',
                            axisPointer: {
                                type: 'line'
                            }
                        },
                        grid: {
                            left: '3%',
                            right: '10%',
                            bottom: '3%',
                            containLabel: true
                        },
                        xAxis: [
                            {
                                type: 'category',
                                data: category,
                                name: '市级地区及海外'
                            }
                        ],
                        yAxis: [
                            {
                                type: 'value',
                                name: '访问量（IP）'
                            }
                        ],
                        series: [
                            {
                                name: '访问量',
                                type: 'bar',
                                barWidth: '40%',
                                data: data
                            }
                        ]
                    };
                    region.barchart.setOption(baroption);
                }
            });
        }
        region.init();
    });
</script>